


//删除该窗帘
function deleteChuangHu(object){
	alert("删除该窗帘,这只是测试, 代码还没实现!");
}
//删除该布
function deleteBu(object){
	alert("删除该布,这只是测试, 代码还没实现!");
}
//纱尺寸输入


//下安装单
function toAddInstall(object){
	success("正在下单中........");
	var rootDiv=$(object).prev().prev();
	var form=rootDiv.find("form");
	if(form.length==1){
		var oneForm=form.first();
		//这第一个form是填写的一个一些基本的信息
		var context=$(oneForm).serialize();
		context =decodeURIComponent(context,true);
		context =JSON.parse(updateString(context));
		var date = context.subscribeTime;
		date = date.substring(0,19);
		date = date.replace(/\+/g," ");
		date = date.replace(/-/g,'/'); 
		var timestamp = new Date(date).getTime();
		$.post(
				"../taskManage/toAddInstall.do",
				{
					name:context.name,
					phone:context.phone,
					subscribeTime:timestamp,
					city:context.Province2+context.City2,
					address:context.installAdress,
					quHAddress:context.Province+context.City+context.quhuo
				},
				function(data){
					//TODO 没有窗帘信息的返回信息
					if(data!=null){
						success("安装订单添加成功!!!,请去我的订单--安装订单---未支付----添加商品")
						setTimeout(myfresh,2000);
					}
					
				}
		
		);
	
	}else if(form.length>1) {
		var dataArray=new Array();
		$.each(form,function(i,oneForm){
			if(i==0){
			}else{
				//这是form表格提交的信息
				var context=$(oneForm).serialize();
				context =decodeURIComponent(context,true);
				context =JSON.parse(updateString(context));
				//图片都传到后台, 然后生成地址
				var formId=$(oneForm).attr("id");
				//布存的所有信息  bu_表格id
				var bumishu=$(oneForm).data("bu_"+formId);
				//纱存的所有信息  sha_表格id
				var shamishu=$(oneForm).data("sha_"+formId);
				//帘头存的所有信息 liantou_表格id
				var toumishu=$(oneForm).data("liantou_"+formId);
				//尺寸存的所有信息 chicun_表格id
				var chicun=$(oneForm).data("chicun_"+formId);
				context.bumishu=bumishu;
				context.shamishu=shamishu;
				context.toumishu=toumishu;
				$.each($(oneForm).find('img'),function(aa,imgaa){
					if(aa==1){
						context.merchantsImg=$(imgaa).attr("src");
					}
				});
				if(typeof(bumishu)=="undefined"&&typeof(chicun)=="object"){
					context.bumishu=chicun;
				}
				dataArray[i-1]=context;
				
			}
			
		});
		//有数据的订单提交
		//这第一个form是填写的一个一些基本的信息
		var context=form.first().serialize();
		context =decodeURIComponent(context,true);
		context =JSON.parse(updateString(context));
		var date = context.subscribeTime;
		date = date.substring(0,19);
		date = date.replace(/\+/g," ");
		date = date.replace(/-/g,'/'); 
		if(context.relievedBao!=1){
			context.relievedBao=0;
		}
		var timestamp = new Date(date).getTime();
		$.post(
				"../taskManage/toAddInstall.do",
				{
					name:context.name,
					phone:context.phone,
					subscribeTime:timestamp,
					city:context.Province2+context.City2,
					address:context.installAdress,
					quHAddress:context.Province+context.City+context.quhuo,
					duogechuanglian:JSON.stringify(dataArray),
					relievedBao:context.relievedBao,
					motorNum:context.motorNum
				},
				function(data){
					//TODO 没有窗帘信息的返回信息
					if(data!=null){			
						window.document.write(data);
					}
				}
		
		);	
	}
	


	
	
}



